package ps.net;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;





public class TriggerEventContent implements PacketContent {
    
    int triggerId;
    String sender = "";
    String attrStr = ""; // attributes to trigger event
    
    TriggerEventContent() {
    }
    
    public TriggerEventContent(int triggerId) {
        this.triggerId = triggerId;
    }
    
    @Override
    public void writeContent(OutputStream out) throws IOException {
        // write trigger id
        Packet.write2ByteNumber(out, triggerId);
        // write trigger sender
        Packet.writeString(out, sender);
        // write trigger attrStr
        Packet.writeString(out, attrStr);
    }
    
    @Override
    public void readContent(InputStream in) throws IOException {
        // read trigger id
        triggerId = Packet.read2ByteNumber(in);
        // read trigger name
        sender = Packet.readString(in);
        // read trigger attrStr
        attrStr = Packet.readString(in);
    }
    
    @Override
    public String toString() {
        String ret = "[ TriggerEvent |";
        ret += " triggerId=\"" + triggerId + "\"";
        ret += " sender=\"" + sender + "\"";
        ret += " attrStr=\"" + attrStr + "\"";
        ret += " ]";
        return ret;
    }
    
    public int getTriggerId() {
        return triggerId;
    }
    
    public String getSender() {
        return sender;
    }
    
    public void setSender(String sender) {
        this.sender = sender;
    }
    
    public String getAttrStr() {
        return attrStr;
    }
    
    public void setAttrStr(String attrStr) {
        this.attrStr = attrStr;
    }
    
}
